package com.qf.util;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 2019/11/18
 * Administrator
 * springmvc1118
 * 面向对象面向君  不负代码不负卿
 */
public class MyInterceptorA implements HandlerInterceptor {
    @Override  //在处理方法前执行
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("拦截器A开始执行,url="+request.getRequestURI());
        //return true 表示继续执行 ，false 表示结束执行
        return true;
    }

    @Override  //处理方法执行完，调用的方法
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        System.out.println("拦截器A结束执行");
    }

    @Override //无论是否有异常都要执行
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        System.out.println("无论是否有异常都要执行的A拦截器代码");
    }
}
